package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.search.service.ESManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager")
public class ESManagerController {

    @Autowired
   private ESManagerService esManagerService;

    //构建 ES 索引库
    @GetMapping("/createIndex")
    public Result createIndex(){
        esManagerService.createMappingAndIndex();
        return new Result(true, StatusCode.OK,"商品索引库建立成功");
    }

    //向ES导入所有商品数据
    @GetMapping("/import/all")
    public Result importAll(){
        esManagerService.importAll();
        return new Result(true,StatusCode.OK,"全部商品导入成功");
    }






}
